#include "dominion.h"
#include <stdio.h>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>

int testSmithy()
{
	printf("Testing Smithy.\n");
	//initializations
	struct gameState *G = newGame();
	struct gameState *G2 = (struct gameState*)malloc(sizeof(struct gameState));
	
	srand(time(NULL));
	int r = rand();

	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};

	initializeGame(2, k, r, G);

	// Initialize to situations where smithy ought to work
	// numActions, phase, etc... can be tested on their own
	G->whoseTurn = 0;
	G->phase = 0;
	G->hand[0][0] = smithy;
	G->numActions = 1;
	
	// Copy current state of G to G2 for s2s comparison
	memcpy(G2, G, sizeof(struct gameState));

	printf("Ensuring playCard doesn't err when we try to play smithy.\n");
	assert(playCard(0, 0, 0, 0, G) == 0);
	printf("Test Passed.\n");

	printf("Testing that we gained 3 card.\n");
	assert(G2->handCount[0] == G->handCount[0] - 2);
	printf("Test passed.\n");

	printf("All Tests Passed.\n");
	return 0;
}

int main()
{
	return testSmithy();
}
